Array.prototype.myFilter = function (Fn) {
    if(typeof Fn !== "function") {
        throw("请输入一个函数")
    }
    const res = []
    for(let i = 0; i < this.length; i ++) {
        if(Fn(this[i], i, this)) {
            res.push(this[i])
        }
    }
    return res;
}

const arr = [1,2,3,4]
console.log(arr.myFilter(item => item > 2))